home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / awt / Graphics2D.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  49.2 KB  |  1,139 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Graphics2D.java    1.56 98/10/19
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt;
  16.  
  17. import java.awt.RenderingHints.Key;
  18. import java.awt.geom.AffineTransform;
  19. import java.awt.image.ImageObserver;
  20. import java.awt.image.BufferedImageOp;
  21. import java.awt.image.BufferedImage;
  22. import java.awt.image.RenderedImage;
  23. import java.awt.image.renderable.RenderableImage;
  24. import java.awt.font.GlyphVector;
  25. import java.awt.font.FontRenderContext;
  26. import java.text.AttributedCharacterIterator;
  27. import java.util.Map;
  28.  
  29. /**
  30.  * This <code>Graphics2D</code> class extends the
  31.  * {@link Graphics} class to provide more sophisticated
  32.  * control over geometry, coordinate transformations, color management,
  33.  * and text layout.  This is the fundamental class for rendering
  34.  * 2-dimensional shapes, text and images on the  Java(tm) platform.
  35.  * <p>
  36.  * <h2>Coordinate Spaces</h2>
  37.  * All coordinates passed to a <code>Graphics2D</code> object are specified 
  38.  * in a device-independent coordinate system called User Space, which is
  39.  * used by applications.  The <code>Graphics2D</code> object contains
  40.  * an {@link AffineTransform} object as part of its rendering state
  41.  * that defines how to convert coordinates from user space to
  42.  * device-dependent coordinates in Device Space.
  43.  * <p>
  44.  * Coordinates in device space usually refer to individual device pixels
  45.  * and are aligned on the infinitely thin gaps between these pixels.
  46.  * Some <code>Graphics2D</code> objects can be used to capture rendering 
  47.  * operations for storage into a graphics metafile for playback on a
  48.  * concrete device of unknown physical resolution at a later time.  Since
  49.  * the resolution might not be known when the rendering operations are
  50.  * captured, the <code>Graphics2D</code> <code>Transform</code> is set up
  51.  * to transform user coordinates to a virtual device space that
  52.  * approximates the expected resolution of the target device. Further
  53.  * transformations might need to be applied at playback time if the
  54.  * estimate is incorrect.
  55.  * <p>
  56.  * Some of the operations performed by the rendering attribute objects
  57.  * occur in the device space, but all <code>Graphics2D</code> methods take 
  58.  * user space coordinates.
  59.  * <p>
  60.  * Every <code>Graphics2D</code> object is associated with a target that
  61.  * defines where rendering takes place. A
  62.  * {@link GraphicsConfiguration} object defines the characteristics
  63.  * of the rendering target, such as pixel format and resolution.
  64.  * The same rendering target is used throughout the life of a
  65.  * <code>Graphics2D</code> object. 
  66.  * <p>
  67.  * When creating a <code>Graphics2D</code> object,  the 
  68.  * <code>GraphicsConfiguration</code> 
  69.  * specifies the <a name="#deftransform">default transform</a> for
  70.  * the target of the <code>Graphics2D</code> (a 
  71.  * {@link Component} or {@link Image}).  This default transform maps the
  72.  * user space coordinate system to screen and printer device coordinates
  73.  * such that the origin maps to the upper left hand corner of the
  74.  * target region of the device with increasing X coordinates extending
  75.  * to the right and increasing Y coordinates extending downward.
  76.  * The scaling of the default transform is set to identity for those devices 
  77.  * that are close to 72 dpi, such as screen devices.
  78.  * The scaling of the default transform is set to approximately 72 user 
  79.  * space coordinates per square inch for high resolution devices, such as
  80.  * printers.  For image buffers, the default transform is the
  81.  * <code>Identity</code> transform.
  82.  *
  83.  * <h2>Rendering Process</h2>
  84.  * The Rendering Process can be broken down into four phases that are 
  85.  * controlled by the <code>Graphics2D</code> rendering attributes.
  86.  * The renderer can optimize many of these steps, either by caching the
  87.  * results for future calls, by collapsing multiple virtual steps into
  88.  * a single operation, or by recognizing various attributes as common
  89.  * simple cases that can be eliminated by modifying other parts of the
  90.  * operation.
  91.  * <p>
  92.  * The steps in the rendering process are:
  93.  * <ol>
  94.  * <li>
  95.  * Determine what to render.  
  96.  * <li>
  97.  * Constrain the rendering operation to the current <code>Clip</code>.
  98.  * The <code>Clip</code> is specified by a {@link Shape} in user
  99.  * space and is converted into device space by the current
  100.  * <code>Transform</code> at the time it was modified.
  101.  * <li>
  102.  * Determine what colors to render.
  103.  * <li>
  104.  * Apply the colors to the destination drawing surface using the current
  105.  * {@link Composite} attribute in the <code>Graphics2D</code> context.
  106.  * </ol>
  107.  * <br>
  108.  * The three types of rendering operations, along with details of each 
  109.  * of their particular rendering processes are:
  110.  * <ol>
  111.  * <li>
  112.  * <b><a name="rendershape"><code>Shape</code> operations</a></b>
  113.  * <ol>
  114.  * <li>
  115.  * If the operation is a <code>draw(Shape)</code> operation, then
  116.  * the  {@link Stroke#createStrokedShape(Shape) createStrokedShape} 
  117.  * method on the current {@link Stroke} attribute in the
  118.  * <code>Graphics2D</code> context is used to construct a new
  119.  * <code>Shape</code> object that contains the outline of the specified
  120.  * <code>Shape</code>.
  121.  * <li>
  122.  * The <code>Shape</code> is transformed from user space to device space
  123.  * using the current <code>Transform</code> 
  124.  * in the <code>Graphics2D</code> context.
  125.  * <li>
  126.  * The outline of the <code>Shape</code> is extracted using the 
  127.  * {@link Shape#getPathIterator(AffineTransform) getPathIterator} method of
  128.  * <code>Shape</code>, which returns a
  129.  * {@link java.awt.geom.PathIterator PathIterator}
  130.  * object that iterates along the boundary of the <code>Shape</code>.
  131.  * <li>
  132.  * If the <code>Graphics2D</code> object cannot handle the curved segments
  133.  * that the <code>PathIterator</code> object returns then it can call the 
  134.  * alternate 
  135.  * {@link Shape#getPathIterator(AffineTransform, double) getPathIterator}
  136.  * method of <code>Shape</code>, which flattens the <code>Shape</code>.
  137.  * <li>
  138.  * The current {@link Paint} in the <code>Graphics2D</code> context
  139.  * is queried for a {@link PaintContext}, which specifies the
  140.  * colors to render in device space.
  141.  * </ol>
  142.  * <li>
  143.  * <b><a name=rendertext>Text operations</a></b>
  144.  * <ol>
  145.  * <li>
  146.  * The following steps are used to determine the set of glyphs required
  147.  * to render the indicated <code>String</code>:
  148.  * <ol>
  149.  * <li>
  150.  * If the argument is a <code>String</code>, then the current
  151.  * <code>Font</code> in the <code>Graphics2D</code> context is asked to 
  152.  * convert the Unicode characters in the <code>String</code> into a set of 
  153.  * glyphs for presentation with whatever basic layout and shaping
  154.  * algorithms the font implements.
  155.  * <li>
  156.  * If the argument is an
  157.  * {@link AttributedCharacterIterator},
  158.  * the iterator is asked to convert itself to a
  159.  * {@link java.awt.font.TextLayout TextLayout}
  160.  * using its embedded font attributes. The <code>TextLayout</code>
  161.  * implements more sophisticated glyph layout algorithms that
  162.  * perform Unicode bi-directional layout adjustments automatically
  163.  * for multiple fonts of differing writing directions.
  164.   * <li>
  165.  * If the argument is a
  166.  * {@link GlyphVector}, then the
  167.  * <code>GlyphVector</code> object already contains the appropriate
  168.  * font-specific glyph codes with explicit coordinates for the position of
  169.  * each glyph.
  170.  * </ol>
  171.  * <li>
  172.  * The current <code>Font</code> is queried to obtain outlines for the 
  173.  * indicated glyphs.  These outlines are treated as shapes in user space 
  174.  * relative to the position of each glyph that was determined in step 1.
  175.  * <li>
  176.  * The character outlines are filled as indicated above
  177.  * under <a href="#rendershape"><code>Shape</code> operations</a>.
  178.  * <li>
  179.  * The current <code>Paint</code> is queried for a
  180.  * <code>PaintContext</code>, which specifies
  181.  * the colors to render in device space.
  182.  * </ol>
  183.  * <li>
  184.  * <b><a name= renderingimage><code>Image</code> Operations</a></b>
  185.  * <ol>
  186.  * <li>
  187.  * The region of interest is defined by the bounding box of the source 
  188.  * <code>Image</code>.
  189.  * This bounding box is specified in Image Space, which is the 
  190.  * <code>Image</code> object's local coordinate system. 
  191.  * <li>
  192.  * If an <code>AffineTransform</code> is passed to 
  193.  * {@link #drawImage(java.awt.Image, java.awt.geom.AffineTransform, java.awt.image.ImageObserver) drawImage(Image, AffineTransform, ImageObserver)}, 
  194.  * the <code>AffineTransform</code> is used to transform the bounding
  195.  * box from image space to user space. If no <code>AffineTransform</code> 
  196.  * is supplied, the bounding box is treated as if it is already in user space.
  197.  * <li>
  198.  * The bounding box of the source <code>Image</code> is transformed from user
  199.  * space into device space using the current <code>Transform</code>.
  200.  * Note that the result of transforming the bounding box does not
  201.  * necessarily result in a rectangular region in device space.
  202.  * <li>
  203.  * The <code>Image</code> object determines what colors to render, 
  204.  * sampled according to the source to destination
  205.  * coordinate mapping specified by the current <code>Transform</code> and the
  206.  * optional image transform.
  207.  * </ol>
  208.  * </ol>
  209.  *
  210.  * <h2>Default Rendering Attributes</h2>
  211.  * The default values for the <code>Graphics2D</code> rendering attributes are:
  212.  * <dl compact>
  213.  * <dt><i><code>Paint</code></i>
  214.  * <dd>The color of the <code>Component</code>.
  215.  * <dt><i><code>Font</code></i>
  216.  * <dd>The <code>Font</code> of the <code>Component</code>.
  217.  * <dt><i><code>Stroke</code></i>
  218.  * <dd>A square pen with a linewidth of 1, no dashing, miter segment joins
  219.  * and square end caps.
  220.  * <dt><i><code>Transform</code></i>
  221.  * <dd>The 
  222.  * {@link GraphicsConfiguration#getDefaultTransform() getDefaultTransform} 
  223.  * for the <code>GraphicsConfiguration</code> of the <code>Component</code>.
  224.  * <dt><i><code>Composite</code></i>
  225.  * <dd>The {@link AlphaComposite#SRC_OVER} rule.
  226.  * <dt><i><code>Clip</code></i>
  227.  * <dd>No rendering <code>Clip</code>, the output is clipped to the
  228.  * <code>Component</code>.
  229.  * </dl>
  230.  *
  231.  * <h2>Rendering Compatibility Issues</h2>
  232.  * The JDK(tm) 1.1 rendering model is based on a pixelization model 
  233.  * that specifies that coordinates
  234.  * are infinitely thin, lying between the pixels.  Drawing operations are 
  235.  * performed using a one-pixel wide pen that fills the 
  236.  * pixel below and to the right of the anchor point on the path.  
  237.  * The JDK 1.1 rendering model is consistent with the 
  238.  * capabilities of most of the existing class of platform 
  239.  * renderers that need  to resolve integer coordinates to a 
  240.  * discrete pen that must fall completely on a specified number of pixels.  
  241.  * <p>
  242.  * The Java(tm) 2D (JDK(tm) 1.2) API supports antialiasing renderers. 
  243.  * A pen with a width of one pixel does not need to fall 
  244.  * completely on pixel N as opposed to pixel N+1.  The pen can fall 
  245.  * partially on both pixels. It is not necessary to choose a bias 
  246.  * direction for a wide pen since the blending that occurs along the 
  247.  * pen traversal edges makes the sub-pixel position of the pen 
  248.  * visible to the user.  On the other hand, when antialiasing is 
  249.  * turned off with the ANTIALIAS_OFF hint, the renderer might need 
  250.  * to apply a bias to determine which pixel to modify when the pen 
  251.  * is straddling a pixel boundary, such as when it is drawn
  252.  * along an integer coordinate in device space.  While the capabilities
  253.  * of an antialiasing renderer make it no longer necessary for the
  254.  * rendering model to specify a bias for the pen, it is desirable for the
  255.  * antialiasing and non-antialiasing renderers to perform similarly for
  256.  * the common cases of drawing one-pixel wide horizontal and vertical 
  257.  * lines on the screen.  To ensure that turning on the ANTIALIAS hint
  258.  * does not cause such lines to suddenly become twice as wide and half
  259.  * as opaque, it is desirable to have the model specify a path for such
  260.  * lines so that they completely cover a particular set of pixels to help
  261.  * increase their crispness.
  262.  * <p>
  263.  * Java 2D API maintains compatibility with JDK 1.1 rendering 
  264.  * behavior, such that legacy operations and existing renderer
  265.  * behavior is unchanged under Java 2D API.  Legacy
  266.  * methods that map onto general <code>draw</code> and 
  267.  * <code>fill</code> methods are defined, which clearly indicates 
  268.  * how <code>Graphics2D</code> extends <code>Graphics</code> based 
  269.  * on settings of <code>Stroke</code> and <code>Transform</code>
  270.  * attributes and rendering hints.  The definition 
  271.  * performs identically under default attribute settings.  
  272.  * For example, the default <code>Stroke</code> is a 
  273.  * <code>BasicStroke</code> with a width of 1 and no dashing and the
  274.  * default Transform for screen drawing is an Identity transform.  
  275.  * <p>
  276.  * The following two rules provide predictable rendering behavior whether
  277.  * aliasing or antialiasing is being used.
  278.  * <ul>
  279.  * <li> Device coordinates are defined to be between device pixels which
  280.  * avoids any inconsistent results between aliased and antaliased
  281.  * rendering.  If coordinates were defined to be at a pixel's center, some
  282.  * of the pixels covered by a shape, such as a rectangle, would only be
  283.  * half covered.
  284.  * With aliased rendering, the half covered pixels would either be 
  285.  * rendered inside the shape or outside the shape.  With anti-aliased
  286.  * rendering, the pixels on the entire edge of the shape would be half
  287.  * covered.  On the other hand, since coordinates are defined to be
  288.  * between pixels, a shape like a rectangle would have no half covered
  289.  * pixels, whether or not it is rendered using antialiasing. 
  290.  * <li> The <code>BasicStroke</code> object always applies a
  291.  * (0.5, 0.5) user space translation to its pen before stroking a
  292.  * path.  The result of this translation is that for the default
  293.  * <code>BasicStroke</code> with a width of 1 user space unit, the
  294.  * line is offset entirely below and to the right of the path.
  295.  * This rule also maintains similar visual results when the same path is
  296.  * stroked in a scaled coordinate system, such as when rendered to a
  297.  * printer, and also when antialiasing is turned on.  In all 3 cases, the
  298.  * bias that was required when the line was drawn in a 1:1 coordinate
  299.  * system and discrete pixels had to be chosen are consistent 
  300.  * regardless of coordinate scaling or choice of antialiasing hint.
  301.  * </ul>
  302.  * <p>
  303.  * The following definitions of general legacy methods 
  304.  * perform identically to previously specified behavior under default 
  305.  * attribute settings:
  306.  * <ul>
  307.  * <li>
  308.  * For <code>fill</code> operations, including <code>fillRect</code>, 
  309.  * <code>fillRoundRect</code>, <code>fillOval</code>,
  310.  * <code>fillArc</code>, <code>fillPolygon</code>, and 
  311.  * <code>clearRect</code>, {@link #fill(Shape) fill} can now be called
  312.  * with the desired <code>Shape</code>.  For example, when filling a
  313.  * rectangle:
  314.  * <pre>
  315.  * fill(new Rectangle(x, y, w, h));
  316.  * </pre>
  317.  * is called.
  318.  * <p>
  319.  * <li>
  320.  * Similarly, for draw operations, including <code>drawLine</code>, 
  321.  * <code>drawRect</code>, <code>drawRoundRect</code>,
  322.  * <code>drawOval</code>, <code>drawArc</code>, <code>drawPolyline</code>,
  323.  * and <code>drawPolygon</code>, {@link #draw(Shape) draw} can now be
  324.  * called with the desired <code>Shape</code>.  For example, when drawing a
  325.  * rectangle:
  326.  * <pre>
  327.  * draw(new Rectangle(x, y, w, h));
  328.  * </pre>
  329.  * is called.
  330.  * <p>
  331.  * <li>
  332.  * The <code>draw3DRect</code> and <code>fill3DRect</code> methods were
  333.  * implemented in terms of the <code>drawLine</code> and 
  334.  * <code>fillRect</code> methods in the <code>Graphics</code> class which
  335.  * would predicate their behavior upon the current <code>Stroke</code>
  336.  * and <code>Paint</code> objects in a <code>Graphics2D</code> context.
  337.  * This class overrides those implementations with versions that use
  338.  * the current <code>Color</code> exclusively, overriding the current
  339.  * <code>Paint</code> and which uses <code>fillRect</code> to describe
  340.  * the exact same behavior as the preexisting methods regardless of the
  341.  * setting of the current <code>Stroke</code>.
  342.  * </ul>
  343.  * The <code>Graphics</code> class defines only the <code>setColor</code>
  344.  * method to control the color to be painted.  Since the Java 2D API extends
  345.  * the <code>Color</code> object to implement the new <code>Paint</code> 
  346.  * interface, the existing
  347.  * <code>setColor</code> method is now a convenience method for setting the 
  348.  * current <code>Paint</code> attribute to a <code>Color</code> object.  
  349.  * <code>setColor(c)</code> is equivalent to <code>setPaint(c)</code>.
  350.  * <p>
  351.  * The <code>Graphics</code> class defines two methods for controlling
  352.  * how colors are applied to the destination.
  353.  * <ol>
  354.  * <li>
  355.  * The <code>setPaintMode</code> method is implemented as a convenience
  356.  * method to set the default <code>Composite</code>, equivalent to
  357.  * <code>setComposite(new AlphaComposite.SrcOver)</code>.
  358.  * <li>
  359.  * The <code>setXORMode(Color xorcolor)</code> method is implemented
  360.  * as a convenience method to set a special <code>Composite</code> object that
  361.  * ignores the <code>Alpha</code> components of source colors and sets the
  362.  * destination color to the value:
  363.  * <pre>
  364.  * dstpixel = (PixelOf(srccolor) ^ PixelOf(xorcolor) ^ dstpixel);
  365.  * </pre>
  366.  * </ol>
  367.  *
  368.  * @version 10-Feb-97
  369.  * @author Jim Graham
  370.  */
  371. public abstract class Graphics2D extends Graphics {
  372.  
  373.     /**
  374.      * Constructs a new <code>Graphics2D</code> object.  Since 
  375.      * <code>Graphics2D</code> is an abstract class, and since it must be
  376.      * customized by subclasses for different output devices,
  377.      * <code>Graphics2D</code> objects cannot be created directly.
  378.      * Instead, <code>Graphics2D</code> objects must be obtained from another 
  379.      * <code>Graphics2D</code> object, created by a 
  380.      * <code>Component</code>, or obtained from images such as
  381.      * {@link BufferedImage} objects.
  382.      * @see java.awt.Component#getGraphics
  383.      * @see java.awt.Graphics#create
  384.      */
  385.     protected Graphics2D() {
  386.     }
  387.  
  388.     /**
  389.      * Draws a 3-D highlighted outline of the specified rectangle.
  390.      * The edges of the rectangle are highlighted so that they
  391.      * appear to be beveled and lit from the upper left corner.
  392.      * <p>
  393.      * The colors used for the highlighting effect are determined 
  394.      * based on the current color.
  395.      * The resulting rectangle covers an area that is 
  396.      * <code>width + 1</code> pixels wide
  397.      * by <code>height + 1</code> pixels tall.  This method
  398.      * uses the current <code>Color</code> exclusively and ignores
  399.      * the current <code>Paint</code>.
  400.      * @param x, y the coordinates of the rectangle to be drawn.
  401.      * @param width the width of the rectangle to be drawn.
  402.      * @param height the height of the rectangle to be drawn.
  403.      * @param raised a boolean that determines whether the rectangle
  404.      *                      appears to be raised above the surface 
  405.      *                      or sunk into the surface.
  406.      * @see         java.awt.Graphics#fill3DRect
  407.      */
  408.     public void draw3DRect(int x, int y, int width, int height,
  409.                boolean raised) {
  410.     Paint p = getPaint();
  411.     Color c = getColor();
  412.     Color brighter = c.brighter();
  413.     Color darker = c.darker();
  414.  
  415.     setColor(raised ? brighter : darker);
  416.     //drawLine(x, y, x, y + height);
  417.     fillRect(x, y, 1, height + 1);
  418.     //drawLine(x + 1, y, x + width - 1, y);
  419.     fillRect(x + 1, y, width - 1, 1);
  420.     setColor(raised ? darker : brighter);
  421.     //drawLine(x + 1, y + height, x + width, y + height);
  422.     fillRect(x + 1, y + height, width, 1);
  423.     //drawLine(x + width, y, x + width, y + height - 1);
  424.     fillRect(x + width, y, 1, height);
  425.     setPaint(p);
  426.     }    
  427.  
  428.     /**
  429.      * Paints a 3-D highlighted rectangle filled with the current color.
  430.      * The edges of the rectangle are highlighted so that it appears
  431.      * as if the edges were beveled and lit from the upper left corner.
  432.      * The colors used for the highlighting effect and for filling are
  433.      * determined from the current <code>Color</code>.  This method uses
  434.      * the current <code>Color</code> exclusively and ignores the current 
  435.      * <code>Paint</code>.
  436.      * @param x, y the coordinates of the rectangle to be filled.
  437.      * @param       width the width of the rectangle to be filled.
  438.      * @param       height the height of the rectangle to be filled.
  439.      * @param       raised a boolean value that determines whether the 
  440.      *                      rectangle appears to be raised above the surface 
  441.      *                      or etched into the surface.
  442.      * @see         java.awt.Graphics#draw3DRect
  443.      */
  444.     public void fill3DRect(int x, int y, int width, int height,
  445.                boolean raised) {
  446.     Paint p = getPaint();
  447.     Color c = getColor();
  448.     Color brighter = c.brighter();
  449.     Color darker = c.darker();
  450.  
  451.     if (!raised) {
  452.         setColor(darker);
  453.     } else if (p != c) {
  454.         setColor(c);
  455.     }
  456.     fillRect(x+1, y+1, width-2, height-2);
  457.     setColor(raised ? brighter : darker);
  458.     //drawLine(x, y, x, y + height - 1);
  459.     fillRect(x, y, 1, height);
  460.     //drawLine(x + 1, y, x + width - 2, y);
  461.     fillRect(x + 1, y, width - 2, 1);
  462.     setColor(raised ? darker : brighter);
  463.     //drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
  464.     fillRect(x + 1, y + height - 1, width - 1, 1);
  465.     //drawLine(x + width - 1, y, x + width - 1, y + height - 2);
  466.     fillRect(x + width - 1, y, 1, height - 1);
  467.     setPaint(p);
  468.     }    
  469.  
  470.     /**
  471.      * Strokes the outline of a <code>Shape</code> using the settings of the 
  472.      * current <code>Graphics2D</code> context.  The rendering attributes
  473.      * applied include the <code>Clip</code>, <code>Transform</code>,
  474.      * <code>Paint</code>, <code>Composite</code> and 
  475.      * <code>Stroke</code> attributes.
  476.      * @param s the <code>Shape</code> to be rendered
  477.      * @see #setStroke
  478.      * @see #setPaint
  479.      * @see java.awt.Graphics#setColor
  480.      * @see #transform
  481.      * @see #setTransform     
  482.      * @see #clip
  483.      * @see #setClip
  484.      * @see #setComposite    
  485.      */
  486.     public abstract void draw(Shape s);
  487.  
  488.     /**
  489.      * Renders an image, applying a transform from image space into user space
  490.      * before drawing.
  491.      * The transformation from user space into device space is done with
  492.      * the current <code>Transform</code> in the <code>Graphics2D</code>.
  493.      * The specified transformation is applied to the image before the
  494.      * transform attribute in the <code>Graphics2D</code> context is applied.
  495.      * The rendering attributes applied include the <code>Clip</code>,
  496.      * <code>Transform</code>, and <code>Composite</code> attributes. 
  497.      * Note that no rendering is done if the specified transform is 
  498.      * noninvertible.
  499.      * @param img the <code>Image</code> to be rendered
  500.      * @param xform the transformation from image space into user space
  501.      * @param obs the {@link ImageObserver}
  502.      * to be notified as more of the <code>Image</code>
  503.      * is converted
  504.      * @return <code>true</code> if the <code>Image</code> is 
  505.      * fully loaded and completely rendered; 
  506.      * <code>false</code> if the <code>Image</code> is still being loaded.
  507.      * @see #transform
  508.      * @see #setTransform
  509.      * @see #setComposite
  510.      * @see #clip
  511.      * @see #setClip
  512.      */
  513.     public abstract boolean drawImage(Image img,
  514.                                       AffineTransform xform,
  515.                                       ImageObserver obs);
  516.  
  517.     /**
  518.      * Renders a <code>BufferedImage</code> that is
  519.      * filtered with a 
  520.      * {@link BufferedImageOp}.
  521.      * The rendering attributes applied include the <code>Clip</code>,
  522.      * <code>Transform</code>
  523.      * and <code>Composite</code> attributes.  This is equivalent to:
  524.      * <pre>
  525.      * img1 = op.filter(img, null);
  526.      * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
  527.      * </pre>
  528.      * @param op the filter to be applied to the image before rendering
  529.      * @param img the <code>BufferedImage</code> to be rendered
  530.      * @param x, y the location in user space where the upper left
  531.      * corner of the
  532.      * image is rendered
  533.      * @see #transform
  534.      * @see #setTransform
  535.      * @see #setComposite
  536.      * @see #clip
  537.      * @see #setClip
  538.      */
  539.     public abstract void drawImage(BufferedImage img,
  540.                    BufferedImageOp op,
  541.                    int x,
  542.                    int y);
  543.  
  544.     /**
  545.      * Renders a {@link RenderedImage},
  546.      * applying a transform from image 
  547.      * space into user space before drawing.
  548.      * The transformation from user space into device space is done with
  549.      * the current <code>Transform</code> in the <code>Graphics2D</code>.
  550.      * The specified transformation is applied to the image before the
  551.      * transform attribute in the <code>Graphics2D</code> context is applied.
  552.      * The rendering attributes applied include the <code>Clip</code>,
  553.      * <code>Transform</code>, and <code>Composite</code> attributes. Note
  554.      * that no rendering is done if the specified transform is
  555.      * noninvertible.
  556.      * @param img the image to be rendered
  557.      * @param xform the transformation from image space into user space
  558.      * @see #transform
  559.      * @see #setTransform
  560.      * @see #setComposite
  561.      * @see #clip
  562.      * @see #setClip
  563.      */
  564.     public abstract void drawRenderedImage(RenderedImage img,
  565.                                            AffineTransform xform);
  566.  
  567.     /**
  568.      * Renders a 
  569.      * {@link RenderableImage},
  570.      * applying a transform from image space into user space before drawing.
  571.      * The transformation from user space into device space is done with
  572.      * the current <code>Transform</code> in the <code>Graphics2D</code>.
  573.      * The specified transformation is applied to the image before the
  574.      * transform attribute in the <code>Graphics2D</code> context is applied.
  575.      * The rendering attributes applied include the <code>Clip</code>,
  576.      * <code>Transform</code>, and <code>Composite</code> attributes. Note
  577.      * that no rendering is done if the specified transform is
  578.      * noninvertible.
  579.      *<p> 
  580.      * Rendering hints set on the <code>Graphics2D</code> object might
  581.      * be used in rendering the <code>RenderableImage</code>.  
  582.      * If explicit control is required over specific hints recognized by a 
  583.      * specific <code>RenderableImage</code>, or if knowledge of which hints 
  584.      * are used is required, then a <code>RenderedImage</code> should be   
  585.      * obtained directly from the <code>RenderableImage</code>
  586.      * and rendered using 
  587.      *{@link #drawRenderedImage(RenderedImage, AffineTransform) drawRenderedImage}.
  588.      * @param img the image to be rendered
  589.      * @param xform the transformation from image space into user space
  590.      * @see #transform
  591.      * @see #setTransform
  592.      * @see #setComposite
  593.      * @see #clip
  594.      * @see #setClip
  595.      * @see #drawRenderedImage
  596.      */
  597.     public abstract void drawRenderableImage(RenderableImage img,
  598.                                              AffineTransform xform);
  599.  
  600.     /** 
  601.      * Renders the text of the specified <code>String</code>, using the 
  602.      * current <code>Font</code> and <code>Paint</code> attributes in the 
  603.      * <code>Graphics2D</code> context. 
  604.      * The baseline of the 
  605.      * first character is at position (<i>x</i>, <i>y</i>) in 
  606.      * the User Space. 
  607.      * The rendering attributes applied include the <code>Clip</code>,
  608.      * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and
  609.      * <code>Composite</code> attributes.  For characters in script 
  610.      * systems such as Hebrew and Arabic, the glyphs can be rendered from
  611.      * right to left, in which case the coordinate supplied is the
  612.      * location of the leftmost character on the baseline.
  613.      * @param str the string to be rendered
  614.      * @param x, y the coordinates where the <code>String</code>
  615.      * should be rendered
  616.      * @see         java.awt.Graphics#drawBytes
  617.      * @see         java.awt.Graphics#drawChars
  618.      * @since       JDK1.0
  619.      */
  620.     public abstract void drawString(String str, int x, int y);
  621.  
  622.     /**
  623.      * Renders the text specified by the specified <code>String</code>, 
  624.      * using the current <code>Font</code> and <code>Paint</code> attributes 
  625.      * in the <code>Graphics2D</code> context. 
  626.      * The baseline of the first character is at position 
  627.      * (<i>x</i>, <i>y</i>) in the User Space.
  628.      * The rendering attributes applied include the <code>Clip</code>,
  629.      * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and
  630.      * <code>Composite</code> attributes. For characters in script systems 
  631.      * such as Hebrew and Arabic, the glyphs can be rendered from right to
  632.      * left, in which case the coordinate supplied is the location of the
  633.      * leftmost character on the baseline.
  634.      * @param s the <code>String</code> to be rendered
  635.      * @param x, y the coordinates where the <code>String</code>
  636.      * should be rendered
  637.      * @see #setPaint
  638.      * @see java.awt.Graphics#setColor
  639.      * @see java.awt.Graphics#setFont
  640.      * @see #setTransform
  641.      * @see #setComposite
  642.      * @see #setClip
  643.      */
  644.     public abstract void drawString(String s, float x, float y);
  645.  
  646.     /**
  647.      * Renders the text of the specified iterator, using the
  648.      * <code>Graphics2D</code> context's current <code>Paint</code>. The 
  649.      * iterator has to specify a font
  650.      * for each character. The baseline of the 
  651.      * first character is at position (<i>x</i>, <i>y</i>) in the 
  652.      * User Space. 
  653.      * The rendering attributes applied include the <code>Clip</code>,
  654.      * <code>Transform</code>, <code>Paint</code>, and
  655.      * <code>Composite</code> attributes.
  656.      * For characters in script systems such as Hebrew and Arabic,
  657.      * the glyphs can be rendered from right to left, in which case the 
  658.      * coordinate supplied is the location of the leftmost character
  659.      * on the baseline.
  660.      * @param iterator the iterator whose text is to be rendered
  661.      * @param x, y the coordinates where the iterator's text is to be
  662.      * rendered
  663.      * @see #setPaint
  664.      * @see java.awt.Graphics#setColor
  665.      * @see #setTransform
  666.      * @see #setComposite
  667.      * @see #setClip
  668.      */
  669.     public abstract void drawString(AttributedCharacterIterator iterator,
  670.                                     int x, int y);
  671.  
  672.     /**
  673.      * Renders the text of the specified iterator, using the 
  674.      * <code>Graphics2D</code> context's current <code>Paint</code>. The 
  675.      * iterator must specify a font
  676.      * for each character. The baseline of the 
  677.      * first character is at position (<i>x</i>, <i>y</i>) in the 
  678.      * User Space. 
  679.      * The rendering attributes applied include the <code>Clip</code>,
  680.      * <code>Transform</code>, <code>Paint</code>, and
  681.      * <code>Composite</code> attributes.
  682.      * For characters in script systems such as Hebrew and Arabic,
  683.      * the glyphs can be rendered from right to left, in which case the 
  684.      * coordinate supplied is the location of the leftmost character
  685.      * on the baseline.
  686.      * @param iterator the iterator whose text is to be rendered
  687.      * @param x, y the coordinates where the iterator's text is to be
  688.      * rendered
  689.      * @see #setPaint
  690.      * @see java.awt.Graphics#setColor
  691.      * @see #setTransform
  692.      * @see #setComposite
  693.      * @see #setClip
  694.      */
  695.     public abstract void drawString(AttributedCharacterIterator iterator,
  696.                                     float x, float y);
  697.  
  698.     /**
  699.      * Renders the text of the specified 
  700.      * {@link GlyphVector} using
  701.      * the <code>Graphics2D</code> context's rendering attributes.
  702.      * The rendering attributes applied include the <code>Clip</code>,
  703.      * <code>Transform</code>, <code>Paint</code>, and
  704.      * <code>Composite</code> attributes.  The <code>GlyphVector</code>
  705.      * specifies individual glyphs from a {@link Font}.
  706.      * The <code>GlyphVector</code> can also contain the glyph positions.  
  707.      * This is the fastest way to render a set of characters to the
  708.      * screen.
  709.      * @param g the <code>GlyphVector</code> to be rendered
  710.      * @param x, y the position in User Space where the glyphs should
  711.      * be rendered
  712.      *
  713.      * @see java.awt.font#createGlyphVector
  714.      * @see java.awt.font.GlyphVector
  715.      * @see #setPaint
  716.      * @see java.awt.Graphics#setColor
  717.      * @see #setTransform
  718.      * @see #setComposite
  719.      * @see #setClip
  720.      */
  721.     public abstract void drawGlyphVector(GlyphVector g, float x, float y);
  722.  
  723.     /**
  724.      * Fills the interior of a <code>Shape</code> using the settings of the   
  725.      * <code>Graphics2D</code> context. The rendering attributes applied 
  726.      * include the <code>Clip</code>, <code>Transform</code>,
  727.      * <code>Paint</code>, and <code>Composite</code>.
  728.      * @param s the <code>Shape</code> to be filled
  729.      * @see #setPaint
  730.      * @see java.awt.Graphics#setColor
  731.      * @see #transform
  732.      * @see #setTransform
  733.      * @see #setComposite
  734.      * @see #clip
  735.      * @see #setClip
  736.      */
  737.     public abstract void fill(Shape s);
  738.  
  739.     /**
  740.      * Checks whether or not the specified <code>Shape</code> intersects 
  741.      * the specified {@link Rectangle}, which is in device
  742.      * space. If <code>onStroke</code> is false, this method checks
  743.      * whether or not the interior of the specified <code>Shape</code>
  744.      * intersects the specified <code>Rectangle</code>.  If 
  745.      * <code>onStroke</code> is <code>true</code>, this method checks
  746.      * whether or not the <code>Stroke</code> of the specified 
  747.      * <code>Shape</code> outline intersects the specified
  748.      * <code>Rectangle</code>.
  749.      * The rendering attributes taken into account include the
  750.      * <code>Clip</code>, <code>Transform</code>, and <code>Stroke</code> 
  751.      * attributes.
  752.      * @param rect the area in device space to check for a hit
  753.      * @param s the <code>Shape</code> to check for a hit
  754.      * @param onStroke flag used to choose between testing the 
  755.      * stroked or the filled shape.  If the flag is <code>true</code>, the 
  756.      * <code>Stroke</code> oultine is tested.  If the flag is 
  757.      * <code>false</code>, the filled <code>Shape</code> is tested.
  758.      * @return <code>true</code> if there is a hit; <code>false</code> 
  759.      * otherwise.
  760.      * @see #setStroke
  761.      * @see #fill
  762.      * @see #draw
  763.      * @see #transform
  764.      * @see #setTransform
  765.      * @see #clip
  766.      * @see #setClip
  767.      */
  768.     public abstract boolean hit(Rectangle rect,
  769.                 Shape s,
  770.                 boolean onStroke);
  771.  
  772.     /**
  773.      * Returns the device configuration associated with this 
  774.      * <code>Graphics2D</code>.
  775.      */
  776.     public abstract GraphicsConfiguration getDeviceConfiguration();
  777.  
  778.     /**
  779.      * Sets the <code>Composite</code> for the <code>Graphics2D</code> context.
  780.      * The <code>Composite</code> is used in all drawing methods such as 
  781.      * <code>drawImage</code>, <code>drawString</code>, <code>draw</code>,
  782.      * and <code>fill</code>.  It specifies how new pixels are to be combined 
  783.      * with the existing pixels on the graphics device during the rendering 
  784.      * process.
  785.      * <p>If this <code>Graphics2D</code> context is drawing to a
  786.      * <code>Component</code> on the display screen and the
  787.      * <code>Composite</code> is a custom object rather than an
  788.      * instance of the <code>AlphaComposite</code> class, and if
  789.      * there is a security manager, its <code>checkPermission</code>
  790.      * method is called with an <code>AWTPermission("readDisplayPixels")</code>
  791.      * permission.
  792.      * @throws SecurityException
  793.      *         if a custom <code>Composite</code> object is being
  794.      *         used to render to the screen and a security manager
  795.      *         is set and its <code>checkPermission</code> method
  796.      *         does not allow the operation.
  797.      * @param comp the <code>Composite</code> object to be used for rendering
  798.      * @see java.awt.Graphics#setXORMode
  799.      * @see java.awt.Graphics#setPaintMode
  800.      * @see AlphaComposite
  801.      * @see SecurityManager#checkPermission
  802.      * @see java.awt.AWTPermission
  803.      */
  804.     public abstract void setComposite(Composite comp);
  805.  
  806.     /**
  807.      * Sets the <code>Paint</code> attribute for the 
  808.      * <code>Graphics2D</code> context.
  809.      * @param paint the <code>Paint</code> object to be used to generate 
  810.      * color during the rendering process
  811.      * @see java.awt.Graphics#setColor
  812.      * @see GradientPaint
  813.      * @see TexturePaint
  814.      */
  815.     public abstract void setPaint( Paint paint );
  816.  
  817.     /**
  818.      * Sets the <code>Stroke</code> for the <code>Graphics2D</code> context.
  819.      * @param s the <code>Stroke</code> object to be used to stroke a 
  820.      * <code>Shape</code> during the rendering process
  821.      * @see BasicStroke
  822.      */
  823.     public abstract void setStroke(Stroke s);
  824.  
  825.     /**
  826.      * Sets the value of a single preference for the rendering algorithms.
  827.      * Hint categories include controls for rendering quality and overall 
  828.      * time/quality trade-off in the rendering process.  Refer to the
  829.      * <code>RenderingHints</code> class for definitions of some common
  830.      * keys and values.
  831.      * @param hintKey the key of the hint to be set.
  832.      * @param hintValue the value indicating preferences for the specified
  833.      * hint category.
  834.      * @see RenderingHints
  835.      */
  836.     public abstract void setRenderingHint(Key hintKey, Object hintValue);
  837.  
  838.     /**
  839.      * Returns the value of a single preference for the rendering algorithms.
  840.      * Hint categories include controls for rendering quality and overall 
  841.      * time/quality trade-off in the rendering process.  Refer to the
  842.      * <code>RenderingHints</code> class for definitions of some common
  843.      * keys and values.
  844.      * @param hintKey the key corresponding to the hint to get. 
  845.      * @return an object representing the value for the specified hint key.
  846.      * Some of the keys and their associated values are defined in the
  847.      * <code>RenderingHints</code> class.
  848.      * @see RenderingHints
  849.      */
  850.     public abstract Object getRenderingHint(Key hintKey);
  851.  
  852.     /**
  853.      * Replaces the values of all preferences for the rendering
  854.      * algorithms with the specified <code>hints</code>.
  855.      * The existing values for all rendering hints are discarded and
  856.      * the new set of known hints and values are initialized from the
  857.      * specified {@link Map} object.
  858.      * Hint categories include controls for rendering quality and
  859.      * overall time/quality trade-off in the rendering process.
  860.      * Refer to the <code>RenderingHints</code> class for definitions of
  861.      * some common keys and values.
  862.      * @param hints the rendering hints to be set
  863.      * @see RenderingHints
  864.      */
  865.     public abstract void setRenderingHints(Map hints);
  866.  
  867.     /**
  868.      * Sets the values of an arbitrary number of preferences for the
  869.      * rendering algorithms.
  870.      * Only values for the rendering hints that are present in the
  871.      * specified <code>Map</code> object are modified.
  872.      * All other preferences not present in the specified 
  873.      * object are left unmodified.
  874.      * Hint categories include controls for rendering quality and
  875.      * overall time/quality trade-off in the rendering process.
  876.      * Refer to the <code>RenderingHints</code> class for definitions of
  877.      * some common keys and values.
  878.      * @param hints the rendering hints to be set
  879.      * @see RenderingHints
  880.      */
  881.     public abstract void addRenderingHints(Map hints);
  882.  
  883.     /**
  884.      * Gets the preferences for the rendering algorithms.  Hint categories
  885.      * include controls for rendering quality and overall time/quality
  886.      * trade-off in the rendering process.
  887.      * Returns all of the hint key/value pairs that were ever specified in 
  888.      * one operation.  Refer to the
  889.      * <code>RenderingHints</code> class for definitions of some common
  890.      * keys and values.
  891.      * @return a reference to an instance of <code>RenderingHints</code>
  892.      * that contains the current preferences.
  893.      * @see RenderingHints
  894.      */
  895.     public abstract RenderingHints getRenderingHints();
  896.  
  897.     /**
  898.      * Translates the origin of the <code>Graphics2D</code> context to the 
  899.      * point (<i>x</i>, <i>y</i>) in the current coordinate system. 
  900.      * Modifies the <code>Graphics2D</code> context so that its new origin 
  901.      * corresponds to the point (<i>x</i>, <i>y</i>) in the 
  902.      * <code>Graphics2D</code> context's former coordinate system.  All 
  903.      * coordinates used in subsequent rendering operations on this graphics 
  904.      * context are relative to this new origin.
  905.      * @param  x, y  the specified coordinates
  906.      * @since   JDK1.0
  907.      */
  908.     public abstract void translate(int x, int y);
  909.  
  910.     /**
  911.      * Concatenates the current
  912.      * <code>Graphics2D</code> <code>Transform</code> 
  913.      * with a translation transform. 
  914.      * Subsequent rendering is translated by the specified
  915.      * distance relative to the previous position.
  916.      * This is equivalent to calling transform(T), where T is an
  917.      * <code>AffineTransform</code> represented by the following matrix:
  918.      * <pre>
  919.      *        [   1    0    tx  ]
  920.      *        [   0    1    ty  ]
  921.      *        [   0    0    1   ]
  922.      * </pre>
  923.      * @param tx the distance to translate along the x-axis
  924.      * @param ty the distance to translate along the y-axis
  925.      */
  926.     public abstract void translate(double tx, double ty);
  927.  
  928.     /**
  929.      * Concatenates the current <code>Graphics2D</code>
  930.      * <code>Transform</code> with a rotation transform. 
  931.      * Subsequent rendering is rotated by the specified radians relative
  932.      * to the previous origin.
  933.      * This is equivalent to calling <code>transform(R)</code>, where R is an
  934.      * <code>AffineTransform</code> represented by the following matrix:
  935.      * <pre>
  936.      *        [   cos(theta)    -sin(theta)    0   ]
  937.      *        [   sin(theta)     cos(theta)    0   ]
  938.      *        [       0              0         1   ]
  939.      * </pre>
  940.      * Rotating with a positive angle theta rotates points on the positive
  941.      * x axis toward the positive y axis.
  942.      * @param theta the angle of rotation in radians
  943.      */
  944.     public abstract void rotate(double theta);
  945.  
  946.     /**
  947.      * Concatenates the current <code>Graphics2D</code> 
  948.      * <code>Transform</code> with a translated rotation 
  949.      * transform.  Subsequent rendering is transformed by a transform
  950.      * which is constructed by translating to the specified location, 
  951.      * rotating by the specified radians, and translating back by the same
  952.      * amount as the original translation.  This is equivalent to the
  953.      * following sequence of calls:
  954.      * <pre>
  955.      *        translate(x, y);
  956.      *        rotate(theta);
  957.      *        translate(-x, -y);
  958.      * </pre>
  959.      * Rotating with a positive angle theta rotates points on the positive
  960.      * x axis toward the positive y axis.
  961.      * @param theta the angle of rotation in radians
  962.      * @param x, y coordinates of the origin of the rotation
  963.      */
  964.     public abstract void rotate(double theta, double x, double y);
  965.  
  966.     /**
  967.      * Concatenates the current <code>Graphics2D</code>
  968.      * <code>Transform</code> with a scaling transformation 
  969.      * Subsequent rendering is resized according to the specified scaling
  970.      * factors relative to the previous scaling.
  971.      * This is equivalent to calling <code>transform(S)</code>, where S is an
  972.      * <code>AffineTransform</code> represented by the following matrix:
  973.      * <pre>
  974.      *        [   sx   0    0   ]
  975.      *        [   0    sy   0   ]
  976.      *        [   0    0    1   ]
  977.      * </pre>
  978.      * @param sx the amount by which X coordinates in subsequent
  979.      * rendering operations are multiplied relative to previous
  980.      * rendering operations.
  981.      * @param sy the amount by which Y coordinates in subsequent 
  982.      * rendering operations are multiplied relative to previous 
  983.      * rendering operations.
  984.      */
  985.     public abstract void scale(double sx, double sy);
  986.  
  987.     /**
  988.      * Concatenates the current <code>Graphics2D</code>
  989.      * <code>Transform</code> with a shearing transform. 
  990.      * Subsequent renderings are sheared by the specified
  991.      * multiplier relative to the previous position.
  992.      * This is equivalent to calling <code>transform(SH)</code>, where SH
  993.      * is an <code>AffineTransform</code> represented by the following
  994.      * matrix:
  995.      * <pre>
  996.      *        [   1   shx   0   ]
  997.      *        [  shy   1    0   ]
  998.      *        [   0    0    1   ]
  999.      * </pre>
  1000.      * @param shx the multiplier by which coordinates are shifted in 
  1001.      * the positive X axis direction as a function of their Y coordinate
  1002.      * @param shy the multiplier by which coordinates are shifted in
  1003.      * the positive Y axis direction as a function of their X coordinate
  1004.      */
  1005.     public abstract void shear(double shx, double shy);
  1006.  
  1007.     /**
  1008.      * Composes an <code>AffineTransform</code> object with the 
  1009.      * <code>Transform</code> in this <code>Graphics2D</code> according 
  1010.      * to the rule last-specified-first-applied.  If the current
  1011.      * <code>Transform</code> is Cx, the result of composition
  1012.      * with Tx is a new <code>Transform</code> Cx'.  Cx' becomes the
  1013.      * current <code>Transform</code> for this <code>Graphics2D</code>.
  1014.      * Transforming a point p by the updated <code>Transform</code> Cx' is
  1015.      * equivalent to first transforming p by Tx and then transforming
  1016.      * the result by the original <code>Transform</code> Cx.  In other
  1017.      * words, Cx'(p) = Cx(Tx(p)).  A copy of the Tx is made, if necessary,
  1018.      * so further modifications to Tx do not affect rendering.
  1019.      * @param Tx the <code>AffineTransform</code> object to be composed with 
  1020.      * the current <code>Transform</code>
  1021.      * @see #setTransform
  1022.      * @see AffineTransform
  1023.      */
  1024.     public abstract void transform(AffineTransform Tx);
  1025.  
  1026.     /**
  1027.      * Sets the <code>Transform</code> in the <code>Graphics2D</code>
  1028.      * context.
  1029.      * @param Tx the <code>AffineTransform</code> object to be used in the
  1030.      * rendering process
  1031.      * @see #transform
  1032.      * @see AffineTransform
  1033.      */
  1034.     public abstract void setTransform(AffineTransform Tx);
  1035.  
  1036.     /**
  1037.      * Returns a copy of the current <code>Transform</code> in the 
  1038.      * <code>Graphics2D</code> context.
  1039.      * @return the current <code>AffineTransform</code> in the 
  1040.      *             <code>Graphics2D</code> context.
  1041.      * @see #transform
  1042.      * @see #setTransform
  1043.      */
  1044.     public abstract AffineTransform getTransform();
  1045.  
  1046.     /**
  1047.      * Returns the current <code>Paint</code> of the 
  1048.      * <code>Graphics2D</code> context.
  1049.      * @return the current <code>Graphics2D</code> <code>Paint</code>,
  1050.      * which defines a color or pattern.
  1051.      * @see #setPaint
  1052.      * @see java.awt.Graphics#setColor
  1053.      */
  1054.     public abstract Paint getPaint();
  1055.  
  1056.     /**
  1057.      * Returns the current <code>Composite</code> in the
  1058.      * <code>Graphics2D</code> context.
  1059.      * @return the current <code>Graphics2D</code> <code>Composite</code>,
  1060.      *              which defines a compositing style.
  1061.      * @see #setComposite
  1062.      */
  1063.     public abstract Composite getComposite();
  1064.  
  1065.     /**
  1066.      * Sets the background color for the <code>Graphics2D</code> context. 
  1067.      * The background color is used for clearing a region.
  1068.      * When a <code>Graphics2D</code> is constructed for a
  1069.      * <code>Component</code>, the background color is
  1070.      * inherited from the <code>Component</code>. Setting the background color 
  1071.      * in the <code>Graphics2D</code> context only affects the subsequent      
  1072.      * <code>clearRect</code> calls and not the background color of the  
  1073.      * <code>Component</code>.  To change the background
  1074.      * of the <code>Component</code>, use appropriate methods of 
  1075.      * the <code>Component</code>.
  1076.      * @param color the background color that isused in
  1077.      * subsequent calls to <code>clearRect</code>
  1078.      * @see #getBackground
  1079.      * @see java.awt.Graphics#clearRect
  1080.      */
  1081.     public abstract void setBackground(Color color);
  1082.  
  1083.     /**
  1084.      * Returns the background color used for clearing a region.
  1085.      * @return the current <code>Graphics2D</code> <code>Color</code>,
  1086.      * which defines the background color.
  1087.      * @see #setBackground
  1088.      */
  1089.     public abstract Color getBackground();
  1090.  
  1091.     /**
  1092.      * Returns the current <code>Stroke</code> in the
  1093.      * <code>Graphics2D</code> context.
  1094.      * @return the current <code>Graphics2D</code> <code>Stroke</code>,
  1095.      *                 which defines the line style.
  1096.      * @see #setStroke
  1097.      */
  1098.     public abstract Stroke getStroke();
  1099.  
  1100.     /**
  1101.      * Intersects the current <code>Clip</code> with the interior of the
  1102.      * specified <code>Shape</code> and sets the <code>Clip</code> to the
  1103.      * resulting intersection.  The specified <code>Shape</code> is
  1104.      * transformed with the current <code>Graphics2D</code>
  1105.      * <code>Transform</code> before being intersected with the current 
  1106.      * <code>Clip</code>.  This method is used to make the current
  1107.      * <code>Clip</code> smaller.
  1108.      * To make the <code>Clip</code. larger, use <code>setClip</code>.
  1109.      * @param s the <code>Shape</code> to be intersected with the current
  1110.      * <code>Clip</code>
  1111.      */
  1112.      public abstract void clip(Shape s);
  1113.  
  1114.      /**
  1115.      * Get the rendering context of the <code>Font</code> within this 
  1116.      * <code>Graphics2D</code> context.
  1117.      * The {@link FontRenderContext}
  1118.      * encapsulates application hints such as anti-aliasing and 
  1119.      * fractional metrics, as well as target device specific information
  1120.      * such as dots-per-inch.  This information should be provided by the
  1121.      * application when using objects that perform typographical
  1122.      * formatting, such as <code>Font</code> and
  1123.      * <code>TextLayout</code>.  This information should also be provided
  1124.      * by applications that perform their own layout and need accurate
  1125.      * measurements of various characteristics of glyphs such as advance
  1126.      * and line height when various rendering hints have been applied to
  1127.      * the text rendering.
  1128.      *
  1129.      * @return a reference to an instance of FontRenderContext.
  1130.      * @see java.awt.font.FontRenderContext
  1131.      * @see java.awt.Font#createGlyphVector
  1132.      * @see java.awt.font.TextLayout
  1133.      * @since     JDK1.2
  1134.      */
  1135.  
  1136.     public abstract FontRenderContext getFontRenderContext();
  1137.  
  1138. }
  1139.